package com.xdf.zipperdye.service;

import com.xdf.zipperdye.dao.business.PlanMapper;
import com.xdf.zipperdye.model.Plan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PlanServiceImpl implements PlanService {
    @Autowired
    private PlanMapper dao;
    @Autowired
    private BillCodeService billCodeService;

    @Override
    public int deleteByPrimaryKey(Integer iid) {
        return dao.deleteByPrimaryKey(iid);
    }

    @Override
    public Plan insert(Plan record) {
        String billCode = billCodeService.getNewBillCode("生产计划单");
        record.setBill_code(billCode);
        int ret = dao.insert(record);
        return dao.getLast();
    }

    @Override
    public Plan insertSelective(Plan record) {
        String billCode = billCodeService.getNewBillCode("生产计划单");
        record.setBill_code(billCode);
        int ret = dao.insertSelective(record);
        return dao.getLast();
    }

    @Override
    public Plan selectByPrimaryKey(Integer iid) {
        return dao.selectByPrimaryKey(iid);
    }

    @Override
    public int updateByPrimaryKeySelective(Plan record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Plan record) {
        return dao.updateByPrimaryKey(record);
    }

    @Override
    public List<Plan> getBetweenDate(Date sdate, Date edate) {
        return dao.getBetweenDate(sdate, edate);
    }

    @Override
    public Plan getLast() {
        return dao.getLast();
    }

    @Override
    public List<Plan> getPlan8PidState(Integer parentId, Integer state) {
        return dao.getPlan8PidState(parentId, state);
    }

    @Override
    public List<Plan> getPlan8OrderIdState(Integer iid, Integer state) {
        return dao.getPlan8OrderIdState(iid, state);
    }
}
